package com.lgl.generator;

import com.lgl.model.MainTemplateModel;
import freemarker.template.TemplateException;
import org.junit.Test;

import java.io.File;
import java.io.IOException;

/**
 * @author 良哥
 * @verison 1.0
 */
public class MainGenerator {
    public static void main(String[] args) throws IOException, TemplateException {
        String projectPath = System.getProperty("user.dir");

        //  当前path
        String inputPath = new File(projectPath, "sample_pro_all").getAbsolutePath();


        //
        File inputFile = new File(inputPath);
        File outputFile = new File(projectPath);
        StaticGenerator.copyFileByRecursive(inputFile, outputFile);

//        System.out.println(DyinputPath);
//        System.out.println(DyoutputPath);

        MainTemplateModel tmpModel = new MainTemplateModel();
        tmpModel.setAuthor("良哥");
        tmpModel.setIsLoop(false);

        doGen(tmpModel);
    }


    public static void doGen(Object model) throws TemplateException, IOException {

        String projectPath = new File(System.getProperty("user.dir")).getParentFile().getAbsolutePath();

        //
        String DyinputPath = projectPath + "/code_generate_basic/src/main/resources/templates/MainTemplate.java.ftl";
        String DyoutputPath = projectPath + "/code_generate_basic/MainTemplate.java";

        System.out.println(DyoutputPath);
        DynamicGenerator.TemplateConfig(DyinputPath, DyoutputPath, model);
    }

}
